package com.hd.platform.util;

import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Calendar;
import java.util.GregorianCalendar;

public class FileUtil {

	public static boolean mkdir(String path, boolean flag) {
		File file = new File(path);
		if (file.isDirectory() && file.exists()) {
			if (flag)
				return file.mkdirs();
			else
				return file.mkdir();
		}
		return false;
	}

	public static String genPathBydate() {
		GregorianCalendar cal = new GregorianCalendar();
		StringBuffer sbPath = new StringBuffer();
		sbPath.append(cal.get(Calendar.YEAR)).append(File.separator)
				.append(cal.get(Calendar.MONTH) + 1).append(File.separator)
				.append(cal.get(Calendar.DATE)).append(File.separator)
				.append(cal.get(Calendar.HOUR_OF_DAY));
		return sbPath.toString();
	}

	public static String getName(String path) {
		int index = path.lastIndexOf(File.separator);
		if (index < /* prefixLength */3)
			return path.substring(/* prefixLength */3);
		return path.substring(index + 1);
	}



}
